<%@ page language="java" import="java.util.*,edu.fzu.costlog.domain.*"
	pageEncoding="utf-8"%>
<%
	List<CostCategory> categorys = (List<CostCategory>) request
			.getAttribute("categorys");
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>类型记录列表</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

		<style>
.error {
	color: red;
}
</style>

		<script type="text/javascript">
	    function removeCategory(category_id,category_name){
	    
	       if(confirm("您真的要删除编号为 " + category_id + " 的消费记录: " + category_name + " 吗?")){
	          location.href = "costCategoryMgr?act=del&category_id=" + category_id;
	       }
	    }
	    
	    function updateCategory(category_id){
	    
	       location.href = "costCategoryMgr?act=getCategoryById&category_id=" + category_id;
	    }
	</script>

		<style>
body {
	padding: 10px;
}
</style>
	</head>

	<body>
		<h3>
			类型记录列表
		</h3>
		<%
			if (categorys.size() > 0) {
		%>
		<table border="1">
			<tr>
				<th>
					编号
				</th>
				<th>
					类型名称
				</th>
				<th>
					创建时间
				</th>
				<th>
					操作
				</th>
			</tr>
			<%
				for (CostCategory category : categorys) {
			%>
			<tr>
				<td><%=category.getCategoryId()%></td>
				<td><%=category.getCategoryName()%></td>
				<td><%=category.getCreateTime()%></td>
				<td>
					<button onclick="updateCategory(<%=category.getCategoryId()%>);">
						修改
					</button>
					<button
						onclick="removeCategory(<%=category.getCategoryId()%>,'<%=category.getCategoryName()%>');">
						删除
					</button>
				</td>
			</tr>
			<%
				}
			%>
		</table>
		<%
			} else {
		%>
		<span class="error">当前没有任何消费类别记录!</span>
		<%
			}
		%>
	</body>
</html>

